import { createSlice } from '@reduxjs/toolkit'

const configSlice = createSlice({
  name: 'config',
  initialState: {
    config: {
      redgrowth_config: {
        project: 0,
        keyword: '--',
        reply: '--',
      },
      project: 0,
      keyword: '--',
      reply: '--',
    },
  },
  reducers: {
    setConfig: (state, action) => {
      state.config = action.payload
    },
    clearConfig: state => {
      state.config = null
    },
  },
})

export const { setConfig, clearConfig } = configSlice.actions

export const selectConfig = state => state.config.config

export default configSlice.reducer
